home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / difference-clouds.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  3.0 KB  |  78 lines

  1. ; Plugin for the GNU Image Manipulation Program
  2. ; Copyright (C) 2006 Martin Nordholts
  3. ;
  4. ; This program is free software: you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 3 of the License, or
  7. ; (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. ;
  17. ; Renders Difference Clouds onto a layer, i.e. solid noise merged down with the
  18. ; Difference Mode
  19. ;
  20.  
  21. (define (script-fu-difference-clouds image
  22.                                      drawable)
  23.  
  24.   (let* ((draw-offset-x (car (gimp-drawable-offsets drawable)))
  25.          (draw-offset-y (cadr (gimp-drawable-offsets drawable)))
  26.          (has-sel       (car (gimp-drawable-mask-intersect drawable)))
  27.          (sel-offset-x  (cadr (gimp-drawable-mask-intersect drawable)))
  28.          (sel-offset-y  (caddr (gimp-drawable-mask-intersect drawable)))
  29.          (width         (cadddr (gimp-drawable-mask-intersect drawable)))
  30.          (height        (caddr (cddr (gimp-drawable-mask-intersect drawable))))
  31.          (type          (car (gimp-drawable-type-with-alpha drawable)))
  32.          (diff-clouds   (car (gimp-layer-new image width height type
  33.                                              "Clouds" 100 DIFFERENCE-MODE)))
  34.          (offset-x      0)
  35.          (offset-y      0)
  36.         )
  37.  
  38.     (gimp-image-undo-group-start image)
  39.  
  40.     ; Add the cloud layer above the current layer
  41.     (gimp-image-add-layer image diff-clouds -1)
  42.  
  43.     ; Clear the layer (so there are no noise in it)
  44.     (gimp-drawable-fill diff-clouds TRANSPARENT-FILL)
  45.  
  46.     ; Selections are relative to the drawable; adjust the final offset
  47.     (set! offset-x (+ draw-offset-x sel-offset-x))
  48.     (set! offset-y (+ draw-offset-y sel-offset-y))
  49.  
  50.     ; Offset the clouds layer
  51.     (if (gimp-drawable-is-layer drawable)
  52.       (gimp-layer-translate diff-clouds offset-x offset-y))
  53.  
  54.     ; Show the solid noise dialog
  55.     (plug-in-solid-noise SF-RUN-MODE image diff-clouds 0 0 0 1 4.0 4.0)
  56.  
  57.     ; Merge the clouds layer with the layer below
  58.     (gimp-image-merge-down image diff-clouds EXPAND-AS-NECESSARY)
  59.  
  60.     (gimp-image-undo-group-end image)
  61.  
  62.     (gimp-displays-flush)
  63.   )
  64. )
  65.  
  66. (script-fu-register "script-fu-difference-clouds"
  67.                     _"Difference Clouds..."
  68.                     _"Solid noise applied with Difference layer mode"
  69.                     "Martin Nordholts <enselic@hotmail.com>"
  70.                     "Martin Nordholts"
  71.                     "2006/10/25"
  72.                     "RGB* GRAY*"
  73.                     SF-IMAGE       "Image"           0
  74.                     SF-DRAWABLE    "Drawable"        0)
  75.  
  76. (script-fu-menu-register "script-fu-difference-clouds"
  77.              "<Image>/Filters/Render/Clouds")
  78.